<?php

class DAL {

	private $connection;

	function __construct() {
		$this -> connection = mysqli_connect('127.0.0.1', 'root', '', 'nolleregister');
	}

	/**
	 * @return Returns an array containing Attendee arrays
	 */
	public function getAttendees() {
		$attendeeArray = array();
		$result = mysqli_query($this -> connection, "SELECT * FROM nolla");
		while ($row = mysqli_fetch_array($result)) {
			$attendeeArray[] = $row;
		}
		return $attendeeArray;
	}

	public function getContactInfo() {
	}

	public function getMembershipInfo() {
	}

	public function getNollekitInfo() {
	}

	public function getOverallInfo() {
	}

	public function getSittningInfo() {
	}

	/**
	 * @param $socialSecurityNumber indicates which user to fetch data from
	 * @param $table decides which table to fetch data from
	 * @return Array returns an array containing a boolean and a date
	 */
	public function getMemberInfo($socialSecurityNumber, $table) {
		$result = mysqli_query($this -> connection, "SELECT * FROM $table WHERE Personnummer='$socialSecurityNumber'");
		$array = mysqli_fetch_array($result);
		//var_dump($array);
		return $array;
	}
}

//INSERT INTO `nolla`(`Personnummer`, `Förnamn`, `Efternamn`, `KontaktID`, `MedlemskapID`, `OverallID`, `NollekitID`, `Sittning1ID`, `Sittning2ID`, `Sittning3ID`) VALUES (9301019999,"Benny","Noob",2,2,2,2,2,2,2)
